package cn.itcast.service.system.impl;

import cn.itcast.dao.system.SysLogDao;
import cn.itcast.domain.system.SysLog;
import cn.itcast.service.system.SysLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class SysLogServiceImpl implements SysLogService {


    @Autowired
    private SysLogDao sysLogDao;

    //分页查询整个日志
    @Override
    public PageInfo<SysLog> findByPage(Integer pageNum, Integer pageSize, String companyId) {

        //1. 设置当前页与页面大小
        PageHelper.startPage(pageNum,pageSize);

        //2 查询所有
        List<SysLog> sysLogList = sysLogDao.findAll(companyId);


        //3. 创建PageInfo对象
        PageInfo<SysLog> pageInfo = new PageInfo<>(sysLogList);

        return pageInfo;
    }

   
    //添加日志
    @Override
    public void save(SysLog sysLog) {
        //设置一个uuid作为主键

        sysLog.setId(UUID.randomUUID().toString());
        //保存
        sysLogDao.save(sysLog);
    }

   
}
